define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Statistics_groupbuy_agent,$ionicSlideBoxDelegate, $stateParams) {

		//接收参数
		$scope.input = new Object();
		$scope.input.id = $stateParams.id;
		$scope.auction_nums = new Object();
		
		//滑动切换
		$scope.selectTab = 0;
		$scope.activeSlide = function(index) {
			$scope.selectTab = index;
			$ionicSlideBoxDelegate.$getByHandle('tab-handle').slide(index);
		};
	    //滑动切换
		$scope.slideChanged = function(index) {
			$scope.selectTab = index;
		};

		//加载数据
		$scope.init_data = function() {
			//取得热销的商品列表
			Statistics_groupbuy_agent.getinfo($scope.input.id, function(data) {
				$scope.datas = data;
//				var array = data.attention_num;
//				for(var o in array){  
//					if(array[o].region_id){
//						$scope.auction_nums[array[o].region_id] = new Object();
//						$scope.auction_nums[array[o].region_id]['region_id'] = array[o].region_id;
//						$scope.auction_nums[array[o].region_id]['attention_num'] = array[o].number;
//						$scope.auction_nums[array[o].region_id]['region_name'] = array[o].region_name;
//					}
//			    }  
//				array = data.jion_num;
//				for(var o in array){  
//					if($scope.auction_nums[array[o].region_id]){
//						
//					}else{
//						$scope.auction_nums[array[o].region_id] = new Object();
//					}
//					if(array[o].region_id ){
//						$scope.auction_nums[array[o].region_id]['jion_num'] = array[o].number;
//					}
//			    }  
//				array = data.money;
//				for(var o in array){
//					if(array[o].region_id && $scope.auction_nums[array[o].region_id]){
//						$scope.auction_nums[array[o].region_id]['money'] = array[o].money;
//					}
//			    }  
//				array = data.count;
//				for(var o in array){  
//					if(array[o].region_id && $scope.auction_nums[array[o].region_id]){
//						$scope.auction_nums[array[o].region_id]['count'] = array[o].count;
//					}
//			    }  
//				$scope.auction.array = $scope.auction_nums;
//				console.log($scope.auction.array);
			});
		}
		$scope.init_data(); //必须在定义之后

		
		
	}

	controller.$inject = ['$scope', 'Statistics_groupbuy_agent','$ionicSlideBoxDelegate','$stateParams'];
	
	return app.registerController("statistics_groupbuy_agentctrl",controller);
});


